package com.effect.part1_ObjectCrateDestroy.item2;

/**
 * Created by jon on 17-10-7.
 * 重叠构造器模式有许多参数的时候，客户端代码会很难编写，并且难以阅读.
 * 如果客户端不小心颠倒了其中两个参数的顺序，编译也不会出错，但是运行时会遇到问题
 *
 */
public class NutritionFacts_01 {
    private  final  int servingSize ; //(mL)            required
    private  final  int servings ;    //(per container) required
    private  final  int calories;     //                optional
    private  final  int fat;          //(g)             optional
    private  final  int sodium;       //(mg)            optional
    private  final  int carbohydrate; //(g)             optional

    public NutritionFacts_01(int servingSize, int servings) {
        this(servingSize,servings,0);
    }

    public NutritionFacts_01(int servingSize, int servings, int calories) {
        this(servingSize,servings,calories,0);
    }

    public NutritionFacts_01(int servingSize, int servings, int calories, int fat) {
        this(servingSize,servings,calories,fat,0);
    }

    public NutritionFacts_01(int servingSize, int servings, int calories, int fat, int sodium) {
        this(servingSize,servings,calories,fat,sodium,0);
    }

    public NutritionFacts_01(int servingSize, int servings, int calories, int fat, int sodium, int carbohydrate) {
        this.servingSize = servingSize;
        this.servings = servings;
        this.calories = calories;
        this.fat = fat;
        this.sodium = sodium;
        this.carbohydrate = carbohydrate;
    }

    public static void main(String[] args) {
        NutritionFacts_01 cocalCola = new NutritionFacts_01(240,8,100,0,35,27);
    }
}
